package main //必须

import "fmt"

//实现1+2+3+……100
func normalSum() (sum int) {
	for i := 1; i <= 100; i++ {
		sum += i
	}
	return
}

func diguiSum(i int) int {
	if i == 1 {
		return 1
	}

	return i + diguiSum(i-1)
}

func otherSum(i int) int {
	if i == 100 {
		return 100
	}

	return i + otherSum(i+1)
}

func main() {
	sum := 0
	sum = normalSum()
	fmt.Println("normalSum = ", sum)
	sum = diguiSum(100)
	fmt.Println("diguiSum = ", sum)
	sum = otherSum(1)
	fmt.Println("otherSum = ", sum)
}
